#define _CRT_SECURE_NO_WARNINGS 1


#include<vector>
#include<iostream>

using namespace std;

void duplicateZeros(vector<int>& arr)
{
    int dest = -1, cur = 0;
    while (cur < arr.size())
    {
        if (arr[cur] != 0)
        {
            dest++;
        }
        else
        {
            dest += 2;
        }
        if (dest == arr.size() - 1)
        {
            break;
        }
        cur++;
    }
    if (dest == arr.size())
    {
        arr[arr.size() - 1] = 0;
        cur--;
        dest -= 2;
    }
    while (cur >= 0)
    {
        if (arr[cur] != 0)
        {
            arr[dest] = arr[cur];
        }
        else
        {
            arr[dest--] = 0;
            arr[dest] = 0;
        }
        dest--;
        cur--;
    }
}

int main()
{
    vector<int> v = { 0,0,0,0,0,0,0 };
    duplicateZeros(v);


    return 0;
}